package pers.cz.node;

import pers.cz.mxgraph.MxCell;
import pers.cz.selenium.component.ContextComponent;
import pers.cz.websocket.MessagePushSocketUtils;

/**
 * @program: PostGirl-panent
 * @description: 打印输出节点
 * @author: Cheng Zhi
 * @create: 2023-02-03 14:42
 **/
public class PrintNode extends AbstractNode {


    public PrintNode(MxCell mxCell) {
        super(mxCell);
    }

    @Override
    public void runNode(NodeCallBack callBack) throws Exception {

        String operation = mxCell.getMxObjectData().get("operation"); // 休眠时间

        ContextComponent contextComponent = new ContextComponent(getDriver());

        if (operation.equals("1")) {
            // 打印源码
            String source = contextComponent.getSource();
            // 推送前台
            MessagePushSocketUtils.sendMsg(MessagePushSocketUtils.AUTOUI_LOG_MESSAGE, source, 0);
        } else if (operation.equals("2")) {
            String currentUrl = contextComponent.getCurrentUrl();
            MessagePushSocketUtils.sendMsg(MessagePushSocketUtils.AUTOUI_LOG_MESSAGE, currentUrl, 0);
        }
    }

    @Override
    public void verify() {

    }

    @Override
    public String getName() {
        return mxCell.getName();
    }
}
